import {createRouter, createWebHistory,createWebHashHistory} from "vue-router";

const routes = [
  {
    path: '/',
    component: ()=>import('../views/center'),
    children: [
      {
        path: 'shouye',
        component: ()=>import('../views/center/shouye')
      },

      {
        path: 'chanpinzhongxin',
        component: ()=>import('../views/center/chanpinzhongxin')
      },

      {
        path: 'weixiubaoyang',
        component: ()=>import('../views/center/weixiubaoyang')
      },

      {
        path: 'gongsijianjie',
        component: ()=>import('../views/center/gongsijianjie')
      },

      {
        path: 'xinwenzhongxin',
        component: ()=>import('../views/center/xinwenzhongxin')
      },

      {
        path: 'lianxiwomen',
        component: ()=>import('../views/center/lianxiwomen')
      },

      {
        // /search/screens -> /search?q=screens
        path: '',
        redirect: to => {
          // 方法接收目标路由作为参数
          // return 重定向的字符串路径/路径对象
          return {path: '/shouye'}
        },
      },

    ],
  },

]

const router = createRouter({
  // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
  history: createWebHistory(process.env.BASE_URL),
  routes, // `routes: routes` 的缩写
})

export default router
